﻿using System;
using System.IO;
using Monitor.Core.Utilities;
using Yak;

namespace Jobs
{
    internal class Schiebejob
    {
        readonly internal String Quellordner;
        readonly internal String Zielordner;
        readonly internal Int64 Quellgröße;
        readonly internal DriveInfo Quelllaufwerk;
        readonly internal DriveInfo Ziellaufwerk;

        internal Schiebejob(String foo, String bar)
        {
            Quellordner = Path.GetFullPath(foo);
            Zielordner = Path.GetFullPath(bar);
            Quellgröße = FSUtils.DirectorySize(new DirectoryInfo(Quellordner));
            Quelllaufwerk = new DriveInfo(Path.GetPathRoot(Quellordner));
            Ziellaufwerk = new DriveInfo(Path.GetPathRoot(Zielordner));
        }
        override public String ToString()
        {
            return (Quellordner + " (" + FSUtils.GetSizeString(Quellgröße) + ") →  " + Zielordner);
        }
        internal virtual void Execute()
        {
                if (Directory.Exists(Zielordner))
                    Directory.Delete(Zielordner, true);
                FSUtils.CopyDirectory(Quellordner, Zielordner);
                Directory.Delete(Quellordner, true);
        }
    }

    internal class Umleitjob:Schiebejob
    {

        internal Umleitjob(String foo, String bar) : base(foo, bar) { }
        
        override internal void Execute()
        {
            base.Execute();
            NativeMethods.Create(Quellordner, Zielordner, true);
        }
    }
}